package com.zq.server.api.dao;

import com.zq.common.core.domain.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Super
 * @description 针对表【z_userinfo】的数据库操作Mapper
 * @createDate 2024-02-25 20:24:48
 * @Entity .entity.UserInfo
 */
@Mapper
public interface UserInfoMapper {

    /**
     * 根据id获取用户信息
     *
     * @param uId
     * @return UserInfo
     */
    @Select("select * from api_user where id = #{uId}")
    UserInfo getUserInfoByUserId(Long uId);

    /**
     * 根据openid获取用户信息
     *
     * @param openid
     * @return UserInfo
     */
    UserInfo getUserInfoByOpenid(String openid);

    /**
     * 根据openid获取用户信息
     *
     * @param userInfo
     * @return UserInfo
     */
    void save(UserInfo userBuilder);


    /**
     * 修改用户信息
     *
     * @param userInfo
     */
    Integer update(UserInfo userInfo);


    //查找是否有相同手机号
    @Select("SELECT COUNT(*) FROM api_user WHERE u_phone = #{phone} ")
    int getPhoneByPhoneNumber(String phone);


    Integer batchInsert(List<UserInfo> users);
}
